$(function () {
    vm.loadcon();
});

var vm = new Vue({
	el:'#rrapp',
	data:{
        q:{

        },
		showList: true,
	},
	methods: {
		loadcon:function(){
			var url = "jysjxs/querySjByUser";
			$.ajax({
				type: "POST",
			    url: baseURL + url,
			    contentType: "application/json",
			    data: JSON.stringify({state:0,deleteStatus:"0"}),
			    success: function(r){
			    	console.log(r);
			    	var currentTime = new Date();
			    	if(r.code === 0){
						for(var i=0;i<r.list.length;i++){
							var startTime=new Date(r.list[i].exam_start_time);
							var endTime=new Date(r.list[i].exam_end_time);
							var testTime=(parseInt(endTime-startTime))/60000;
							var remainTime = (parseInt(endTime-currentTime))/60000;//本考试剩余时间（分钟）
							$('#testcar').append('<div class="col-sm-3 carbody" ><a class="btnclick" onclick="vm.starTest(\''+r.list[i].id+'\',\''+r.list[i].xsId+'\',\''+encodeURI(r.list[i].name)+'\' ,\''+remainTime+'\')">开始考试</a><p class="testname">'+r.list[i].name+'</p><p class="testcon">开始时间：'+r.list[i].exam_start_time+'</p><p class="testcon">结束时间：'+r.list[i].exam_end_time+'</p><p class="testcon">考试时长：'+testTime+'分钟</p></div>');
						}
					}else{
						alert(r.msg);
					}
				}
			});
		},
		starTest:function(thisid,xsId,thisName,remainTime){
			window.location.href="./exam.html?testId="+thisid +"&testName="+thisName +"&xsId="+xsId +"&remainTime="+remainTime;
		}
	}
});